<?php
    //tool buttons
	$tool_buttons = array();
	if ($this->data['system_table_id'] != null)
	{
		$tool_buttons = array
		(
			'list_button' => array
			(
				'image'=>'btnListLarge.gif', 
				'text'=>LANG_FOR_ALL_TABLES, 
				'url'=>'/'.$this->name.'/edit/'
			)
		);	
	}
	$tool_buttons = $tool_buttons + array
	(
	    'access_list_button' => array
		(
			'image'=>'btnListLarge.gif', 
			'text'=>LANG_SYSTEM_ACCESS_LOGS, 
			'url'=>'/system_access_logs/edit/'
		)
	);
	
	//header
	$this->helpers->htmlx->MenuText1(LANG_TABLES_COLUMNS_LOGS.': '.LANG_EDIT, "edit.gif");
	
	//toolbar
	$this->helpers->toolbars->Toolbar($tool_buttons);

	//table name
    $table_name = "";
    
    if (!empty($this->data['columns_logs']))
    {
    	XHTML::Form('/'.$this->name.'/edit/');
    	echo "<table class = 'grid' cellspacing = '1'>";
    	    
    	    //header row
    	    echo "<tr class = 'ui-widget-header'>";
    			$this->helpers->htmlx->td(ucfirst(LANG_SYSTEM_TABLES_COLUMNS), ' class = "gridHeader" style = "padding: 3px; " ');
    			$this->helpers->htmlx->td(ucfirst(LANG_LOGGED), ' class = "gridHeader" style = "padding: 3px; " align = "center"');	 
    			$this->helpers->htmlx->td(ucfirst(LANG_COMMENTED), ' class = "gridHeader" style = "padding: 3px; " align = "center"');  	
        		XHTML::InputHidden('system_table_id', $this->data['system_table_id']);	
    	    echo "</tr>";
    
    	    //columns
            $i = 1;
        	foreach ($this->data['columns_logs'] as $column_log)
        	{
        		$cellStyle = 'gridCell';
        		
        		echo "<tr class = ''>";
        		
        		    //if new table
            		if ($table_name != $column_log['system_table_name'])
            		{
            		    echo "<tr class = ''> <td colspan = '3' align = 'left' class = '$cellStyle' style = 'font-weight: 900; height: 20px; '>";
            			    echo Language::Get(str_replace('LANG_', '', $column_log['language_constant']), 'CAPITALIZE'); 
            			echo "</td> </tr>";
            		}

            		//column name (translated)
            		echo "<td class='$cellStyle'>";
            		    echo Language::Get(str_replace('LANG_', '', $column_log['system_table_column_constant']), 'LOWERCASE').' ';
            		echo "</td>";
            		
            		//is logged
        			echo "<td class='$cellStyle' align='center'>";
        	    		XHTML::InputCheckbox('column_log['.$column_log[id].'][is_logged]', 1, $column_log['is_logged'], 'id="is_logged'.$column_log['id'].'"  "onclick="if(!this.checked) document.getElementById(\'is_commented'.$column_log['id'].'\').checked=checked"');   		
        	    	    echo "<label for = 'is_logged".$column_log['id']."'></label>";
        	    	echo "</td>";
        	    	
        	    	//is commented
        	    	echo "<td class='$cellStyle' align='center'>";
        	    		XHTML::InputCheckbox('column_log['.$column_log[id].'][is_commented]', 1, $column_log['is_commented'], 'id="is_commented'.$column_log['id'].'"  "onclick="if(this.checked) document.getElementById(\'is_logged'.$column_log['id'].'\').checked=checked" ' );   		
        	    	    echo "<label for = 'is_commented".$column_log['id']."'></label>";
        	    	echo "</td>";
        	    	
             		XHTML::InputHidden('column_log['.$column_log[id].'][id]', $column_log['id']);
             		
                echo "</tr>";
                
        		$table_name = $column_log['system_table_name'];
        		$i++;
        	}	        
    
    	echo "</table>";
    	$this->helpers->htmlx->SubmitTable('submit', 'system_access_logs/edit/');
    	echo "</form>";
    }
    else
    {
        echo "<br />".ucfirst(Language::Get('No columns'))."<br /><br />";
    }
?>